package com.leyou.item.mapper;

import com.leyou.common.mappers.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 新增商品分类和品牌中间表数据
     * @param ids 商品分类id集合
     * @param bid 品牌id
     * @return 新增的条数
     */
    int insertCategoryBrand(@Param("bid") Long bid, @Param("ids") List<Long> ids);

    int deleteCategoryBrand(@Param("id") Long id);

    int selectCategoryBrandCountById(@Param("id")Long id);

    @Select("SELECT b.id, b.name, b.letter, b.image FROM tb_category_brand cb INNER JOIN tb_brand b ON b.id = cb.brand_id WHERE cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(@Param("cid")Long cid);
}